import time
from concurrent.futures import ThreadPoolExecutor, as_completed, ProcessPoolExecutor


def fib(n):
    if n <= 2:
        return 1

    return fib(n-1) + fib(n-2)


if __name__ == '__main__':
    # print(fib(4))
    with ThreadPoolExecutor(3) as executor:  # 多线程
    # with ProcessPoolExecutor(3) as executor:  # 多进程
        tasks = [executor.submit(fib, (num)) for num in range(25, 40)]
        start = time.time()
        for future in as_completed(tasks):
            data = future.result()
            print("resutl = {}".format(data))

        print("cost time:{}".format(time.time() - start))
